#include "stdafx.h"
#include "Main.h"
/******************************************************************************/
void InsertCharacter()
{
   Game::ObjParams op;
   op.type (true, "OBJ_PLAYER");
   op.mesh (true, "obj/chr/human/0.mesh");
   op.phys (true, "obj/chr/human/0.phys");
   op.scale(4);
   op.align(true, ALIGN_NONE, ALIGN_NONE, ALIGN_NONE);
   if(Game::Obj *obj=Game::World.objCreateNear(op, Matrix(1, Vec(0,7,0))))
   {
      if(Player *player=CAST(Player, obj))player->create(op);
   }
}
/******************************************************************************/
Bool LoadingScreen::Loader(Thread &thread)
{
   ThreadMayUseGPUData();
   Game::World.update(Cam.at);
   return false;
}
/******************************************************************************/
void LoadingScreen::del()
{
   Game::World.updateBreak();
   thread.del();
}
void LoadingScreen::start()
{
   thread.create(Loader);
   Renderer.setFade(0.5f, true);
}
/******************************************************************************/
Bool LoadingScreen::update()
{
   if(!thread.created())return false;
   return true;
}
Bool LoadingScreen::draw()
{
   if(!thread.created())return false;
   if(!thread.active()) // finished loading
   {
      thread.del();
      Renderer.setFade(1.0f);
      InsertCharacter();
   }
	D.text(0,-0.9f,S+"Progress : "+Game::World.updateProgress()*100+"%");
   return true;
}
/******************************************************************************/

/******************************************************************************/
